{include="header"}

<script type="text/javascript">
   $(document).ready(function() {
      document.f_custom_search.query.focus();
      $("#b_nueva_familia").click(function(event) {
         event.preventDefault();
         $("#modal_nueva_familia").modal('show');
         document.f_nueva_familia.ncodfamilia.focus();
      });
   });
</script>

<div class="container-fluid" style="margin-top: 10px;">
   <div class="row">
      <div class="col-md-5">
         <div class="btn-group hidden-xs">
            <a class="btn btn-sm btn-default" href="{$fsc->url()}" title="Recargar la página">
               <span class="glyphicon glyphicon-refresh"></span>
            </a>
            {if condition="$fsc->page->is_default()"}
            <a class="btn btn-sm btn-default active" href="{$fsc->url()}&amp;default_page=FALSE" title="desmarcar como página de inicio">
               <span class="glyphicon glyphicon-home"></span>
            </a>
            {else}
            <a class="btn btn-sm btn-default" href="{$fsc->url()}&amp;default_page=TRUE" title="marcar como página de inicio">
               <span class="glyphicon glyphicon-home"></span>
            </a>
            {/if}
         </div>
         
         <div class="btn-group">
            <a id="b_nueva_familia" class="btn btn-sm btn-success" href="#">
               <span class="glyphicon glyphicon-plus"></span> &nbsp; Nueva...
            </a>
            {loop="$fsc->extensions"}
               {if condition="$value->type=='button'"}
               <a href="index.php?page={$value->from}" class="btn btn-sm btn-default">{$value->text}</a>
               {/if}
            {/loop}
         </div>
      </div>
      <div class="col-md-5">
         <h2 style="margin-top: 0px;">Familias de artículos</h2>
      </div>
      <div class="col-md-2 col-sm-3 col-xs-12">
         <form name="f_custom_search" action="{$fsc->url()}" method="post" class="form">
            <div class="input-group">
               <input class="form-control" type="text" name="query" value="{$fsc->query}" autocomplete="off" placeholder="Buscar">
               <span class="input-group-btn">
                  <button class="btn btn-primary" type="submit">
                     <span class="glyphicon glyphicon-search"></span>
                  </button>
               </span>
            </div>
         </form>
      </div>
   </div>
</div>

<div class="container-fluid" style="margin-top: 20px;">
   <div class="row">
      {loop="$fsc->resultados"}
      <div class="col-md-3 col-sm-3" style="margin-bottom: 5px;">
         <a class="btn btn-block btn-default" href="{$value->url()}">{$value->descripcion}</a>
      </div>
      {else}
      <div class="col-md-12 col-sm-12">
         <div class="alert alert-warning">Ninguna familia encontrada. Pulsa el botón <b>Nueva</b> para crear una.</div>
      </div>
      {/loop}
   </div>
</div>

<form class="form" name="f_nueva_familia" action="{$fsc->url()}" method="post">
   <div class="modal" id="modal_nueva_familia">
      <div class="modal-dialog">
         <div class="modal-content">
            <div class="modal-header">
               <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
               <h4 class="modal-title">Nueva familia</h4>
            </div>
            <div class="modal-body">
               <div class="form-group">
                  Código:
                  <input class="form-control" type="text" name="ncodfamilia" maxlength="4" autocomplete="off"/>
               </div>
               <div class="form-group">
                  Descripción:
                  <input class="form-control" type="text" name="ndescripcion" autocomplete="off"/>
               </div>
            </div>
            <div class="modal-footer">
               <button class="btn btn-sm btn-primary" type="submit" onclick="this.disabled=true;this.form.submit();">
                  <span class="glyphicon glyphicon-floppy-disk"></span> &nbsp; Guardar
               </button>
            </div>
         </div>
      </div>
   </div>
</form>

{include="footer"}